﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 开放封闭原则
{
    public class BankProcess2
    {
        public IDeposite? _deposite;
        public ITransfer? _transfer;
        public IBuyJiJin? _buyJiJin;
        public IDrowMoney? _drowMoney;
        public void GetDeposite()
        {
            _deposite?.GetDeposite();
        }
         public void GetDrowMoney()
        {
            _drowMoney?.GetDrowMoney();
        }
        public void GetBuyJiJin()
        {
            _buyJiJin?.GetBuyJiJin();
        }
        public void GetTransfer()
        {
            _transfer?.GetTransfer();
        }
    }

    public class BankStuff2
    {
        private BankProcess2 bankProcess2 = new BankProcess2();
        public void HandleProcess(BankClient bankClient)
        {

            //调用银行的业务系统，处理我们用户的需求；
            switch (bankClient.BankType)
            {
                case "存款":
                    bankProcess2._deposite = new Deposite();
                    bankProcess2._deposite.GetDeposite();
                    break;
                case "取款":
                    bankProcess2._drowMoney = new DrowMoney();
                    bankProcess2._drowMoney.GetDrowMoney();
                    break;
                case "转账":
                    bankProcess2._transfer = new Transfer();
                    bankProcess2._transfer.GetTransfer();
                    break;
                case "购买基金":
                    bankProcess2._buyJiJin = new BuyJiJin();
                    bankProcess2._buyJiJin.GetBuyJiJin();
                    break;
                default:
                    break;
            }
        }
    }
}
